package com.learn.Stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
//流计算
public class StreamDemo {
    public static void main(String[] args) {
        /**
         * 1.求偶数
         * 2.大于3
         * 3.倒序
         * 4.分页1
         */
        List<String> list = new ArrayList(5);
        list.add(0,"A");
        list.add(1,"B");
        list.add(2,"C");
        list.add(3,"D");
        list.add(4,"E");

        List<String> collect = list.stream()
                .filter(u-> list.lastIndexOf(u) % 2 == 0)
                .filter(u-> list.lastIndexOf(u)>=2)
                .sorted((u1,u2)-> u2.compareTo(u1))
                .limit(1)
                .collect(Collectors.toList());
        System.out.println(collect);
    }

}
